<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="java.util.Calendar, com.scalar.chiptrack.utils.ConfigManager"%>

<chiptrack:checkLogon sourcePage="/financeReport.do?action=revenue" />


<HTML><HEAD>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<script>
var dateElement = "";
    function openCalendar(dateValue)
    {
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
    }

    function cancelAndGoBack() {
        document.location = "jsp/finance/finance.jsp";
 }

	function assignDate(passedValue)
    {
	dateElement.value=passedValue;
	window.focus();
    }

	function getQuarter(month,year){

	 Q1From = new Date(year, month-1, "01");
	 var q1_from = new Date(Q1From);
	 Q1To = new Date(Q1From.setMonth(Q1From.getMonth()+3));
	 var q1_to = new Date(Q1To);
	 Q2From = new Date(Q1To.setMonth(Q1To.getMonth()));
	 var q2_from = new Date(Q2From);
	 Q2To = new Date(Q2From.setMonth(Q2From.getMonth()+3));
	 var q2_to = new Date(Q2To);
	 Q3From = new Date(Q2To.setMonth(Q2To.getMonth()));
	 var q3_from = new Date(Q3From);
	 Q3To = new Date(Q3From.setMonth(Q3From.getMonth()+3));
	 var q3_to = new Date(Q3To);
	 Q4From = new Date(Q3To.setMonth(Q3To.getMonth()));
	 var q4_from = new Date(Q4From);
	 Q4To = new Date(Q4From.setMonth(Q4From.getMonth()+3));
	 var q4_to = new Date(Q4To);


     var thisDate = new Date();
	 if (thisDate >= q1_from && thisDate < q1_to)
		 return "quarter1";
	 else if (thisDate >= q2_from && thisDate < q2_to)
 		 return "quarter2";
	 else if (thisDate >= q3_from && thisDate < q3_to)
 		 return "quarter3";
	 else if (thisDate >= q4_from && thisDate < q4_to)
 		 return "quarter4";
	 else
		 return "past";


}

function finance(){

    document.revenueReport.prompt2.value = document.revenueReport.quarter.value;
    document.revenueReport.prompt3.value = document.revenueReport.year.value;

    //var quarter = getQuarter(document.revenueReport.month.value,document.revenueReport.year.value);
    var quarter = document.revenueReport.quarter.value;
    var type="";
    for (counter = 0; counter < revenueReport.type.length; counter++)
	{
		if (revenueReport.type[counter].checked){
			type = revenueReport.type[counter].value;
		}
	}
/* Modified by lavanya , prompts and reports ,July 26 */
    if(quarter=="1"){
        if(type=="PRODUCT"){
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_Qtr.rpt";
        } else if(type=="CUSTOMER") {
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/CUST_REV_RPT_Qtr.rpt";
        }
    }
    else if(quarter=="2") {
        if(type=="PRODUCT"){
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_Qtr.rpt";
        } else if(type=="CUSTOMER") {
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/CUST_REV_RPT_Qtr.rpt";
        }
    }
    else if(quarter=="3"){
        if(type=="PRODUCT"){
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_Qtr.rpt";
        } else if(type=="CUSTOMER") {
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/CUST_REV_RPT_Qtr.rpt";
        }
    }
    else if(quarter=="4"){
        if(type=="PRODUCT"){
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_Qtr.rpt";
        } else if(type=="CUSTOMER") {
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/CUST_REV_RPT_Qtr.rpt";
        }
    }
    else if(quarter=="All"){
        if(type=="PRODUCT"){
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_Past.rpt";
        } else if(type=="CUSTOMER") {
            document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/CUST_REV_RPT_Past.rpt";
        }
    }

    var d = new Date();
		var day = d.getDate();
		var month = d.getMonth()+1;
		var year = d.getFullYear();
		var hour = d.getHours();
		var min = d.getMinutes();
		var sec = d.getSeconds();

		var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    document.revenueReport.prompt6.value = defaultPrompt;

    for (counter = 0; counter < revenueReport.category.length; counter++)
	{
		if (revenueReport.category[counter].checked){
            //alert(revenueReport.category[counter].value);
			document.revenueReport.prompt7.value = revenueReport.category[counter].value;
		}
	}

    document.revenueReport.submit();

/*
    if(document.revenueReport.prompt0.value=='')
    {
    	document.revenueReport.prompt0.value ='0';
    }

    if(document.revenueReport.prompt1.value=='')
    {
	    document.revenueReport.prompt1.value ='0';
    }

    if(document.revenueReport.prompt2.value !='0' && document.revenueReport.prompt3.value =='0')
	{
        document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_product.rpt";
        document.revenueReport.submit();
	}

    else if(document.revenueReport.prompt2.value =='0' && document.revenueReport.prompt3.value!='0')
	{
        document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_customer.rpt";
        document.revenueReport.submit();
	}

    else if(document.revenueReport.prompt2.value !='0' && document.revenueReport.prompt3.value!='0')
	{
        document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_product.rpt";
        document.revenueReport.submit();
	}

    else if(document.revenueReport.prompt2.value =='0' && document.revenueReport.prompt3.value=='0')
	{
        document.revenueReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Finance/Revenue/REV_RPT_default.rpt";
        document.revenueReport.submit();
	}

*/


}
</script>
<TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<form name="revenueReport" method="post">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt6">
<input type="hidden" name="prompt7">
<%--End of Modication by lavanya , July 26 --%>
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/finance/finance_reports_menu.jsp" %>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<center><span class="NArialW">Revenue Reports</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>

  <table border="0" width="90%" align=right>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>

      <td width="15%"><font class="NArialL">Quarter</font></td>
      <td width="20%"><font class="NArialL">
	  <select name="quarter" class="txfield">
           <%-- Prabhanjan, Jul 28, 2004 --%>
           <% String currentQtr = (String) request.getAttribute("currentQtr"); %>
           <logic:iterate id="quarterList" name="quarterList">
        	    <logic:notEqual name="quarterList" value="null">
                    <logic:equal name="quarterList" property="value" value="<%=currentQtr%>">
                        <option value = "<bean:write name="quarterList" property="value"/>" SELECTED>
                            <bean:write name="quarterList" property="label"/>
                        </option>
                    </logic:equal>
                    <logic:notEqual name="quarterList" property="value" value="<%=currentQtr%>">
                        <option value = "<bean:write name="quarterList" property="value"/>" >
                            <bean:write name="quarterList" property="label"/>
                        </option>
                    </logic:notEqual>
                </logic:notEqual>
            </logic:iterate>
            <%--
            <option value="1">Qtr 1</option>
            <option value="2">Qtr 2</option>
            <option value="3">Qtr 3</option>
            <option value="4">Qtr 4</option>
            <option value="All">All</option>
            --%>
        </select>
      </td>

      <%--
      <td width="15%"><font class="NArialL">FY Start Month:</font></td>
      <td width="20%"><font class="NArialL">
	  <select name="month" class="txfield">
      	<option value="01">January</option>
		<option value="02">February</option>
		<option value="03">March</option>
		<option value="04">April</option>
		<option value="05">May</option>
		<option value="06">June</option>
		<option value="07">July</option>
		<option value="08">August</option>
		<option value="09">September</option>
		<option value="10">October</option>
		<option value="11">November</option>
		<option value="12">December</option>
      </td>
      --%>
      	<td width="10%">&nbsp;</td>
      <%--Modified by varma(30jun 2004) --%>
      <%--  <td width="13%"><font class="NArialL">FY Start Year (ex.2002)</font></td> --%>
      <td width="13%"><font class="NArialL">FY Start Year </font></td>
      <td width="20%"><font class="NArialL">
        <%-- Modified by Prabhanjan (10 May 2004) --%>
      	<%-- <input type="text" name="year" value='<%=Calendar.getInstance().get (Calendar.YEAR)%>' size="20" class="txfield"></font>&nbsp;&nbsp;&nbsp;</td> --%>
        <html:select name="revenueReport" property="year" styleClass="txfield" value='<%=Integer.toString(Calendar.getInstance().get (Calendar.YEAR))%>'>
            <%-- <html:option value="">-Select-</html:option> --%>
            <html:options collection="years" property="value" labelProperty="label" />
        </html:select>
       <td width="10%">&nbsp;</td>
    </tr>
 	<tr>
      <td width="25%"><font class="NArialL">Product <br> (<bean:message key="label.mfgPartNumber"/>)</font></td>
	  <td width="20%"><font class="NArialL">
	     	<select size="1" name="prompt0" class="txfield">
	  <option value="0">Select Any product</option>
           <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
	<logic:notEqual name="mktgPartNumberSelectList" value="null">
 <option value = "<bean:write name="mktgPartNumberSelectList" property="productId"/>">
 <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
 </option>
 </logic:notEqual>
 </logic:iterate>  </select>
		</td>

		<td width="10%">&nbsp;</td>
       <td width="15%"><font class="NArialL">Customer</font></td>
	  <td width="20%"><font class="NArialL">
	     	<select size="1" name="prompt1" class="txfield">
	  <option value="0">Select Any Customer</option>
           <logic:iterate id="customerSelectList" name="customerSelectList">
	<logic:notEqual name="customerSelectList" value="null">
 <option value = "<bean:write name="customerSelectList" property="customerId"/>">
 <bean:write name="customerSelectList" property="customerName"/>
 </option>
 </logic:notEqual>
 </logic:iterate>  </select>

		</td>
    </tr>

    <%-- Prabhanjan, Jul 24 2004 --%>

      <tr>
      <td width="25%"><font class="NArialL">Sales Person</font></td>
      <td width="20%"><font class="NArialL">
          <select name="prompt4" class="txfield" >
           <option value="0" >All Sales Persons</option>
           <%-- <html:options collection="salesRepList" property="value" labelProperty="label" /> --%>
           <logic:iterate id="salesRepList" name="salesRepList">
        	    <logic:notEqual name="salesRepList" value="null">
                    <option value = "<bean:write name="salesRepList" />">
                        <bean:write name="salesRepList" />
                    </option>
                </logic:notEqual>
            </logic:iterate>
          </select>
      </td>



      <td width="10%">&nbsp;</td>
<%--      <td width="25%"><font class="NArialL">End User</font></td>--%>
      <td width="25%"><font class="NArialL"><bean:message key="label.sales.endCustomer"/></font></td>
      <td width="20%"><font class="NArialL">
          <select name="prompt5" class="txfield" >
            <option value="0" >Select Any <bean:message key="label.sales.endCustomer"/></option>
            <%-- <html:options collection="endUserList" property="value" labelProperty="label" /> --%>
           <logic:iterate id="endUserList" name="endUserList">
        	    <logic:notEqual name="endUserList" value="null">
                    <option value = "<bean:write name="endUserList" property="value"/>">
                        <bean:write name="endUserList" property="label"/>
                    </option>
                </logic:notEqual>
            </logic:iterate>

          </select>
      </td>
      </tr>
      <%-- End of additions by Prabhanjan, Jul 24 2004 --%>

      <tr>

    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>

    <tr><td colspan=3 align=left>

        <input type="radio" name="type" value="CUSTOMER" checked />
    		<font class="NArialL">Customer</font></td>
    	<td colspan=3 align=left><input type="radio" name="type" value="PRODUCT" />
    		<font class="NArialL">Product (<bean:message key="label.mfgPartNumber"/>)</font>
    </td></tr>

  <%--  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr> --%>

    <tr><td colspan=3 align=left>

        <input type="radio" name="category" value="REQUESTED" checked />
    		<font class="NArialL">Requested Date</font></td>

    	<td colspan=3 align=left><input type="radio" name="category" value="SCHEDULE" />
    		<font class="NArialL">Schedule Date</font>
    </td></tr>

    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>

	<tr>
      <td colspan=5 align=center>
	  <a href="javascript:finance();" onMouseOver="window.status='Click to Generate Revenue Report ';return true" onMouseOut="window.status='';return true" title= "Click here to Generate Revenue Report "><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17"></a>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <%-- <a href="javascript:cancelAndGoBack();" onMouseOver="window.status='Click here to go back to Finance menu';return true" onMouseOut="window.status='';return true">
      <img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"/></a> --%>
      <%--Modified by varma(29 jun 2004) --%>
        <a href="javascript:document.revenueReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
      </td>
    </tr>
  </table>


<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</form>
</BODY>
</HTML>
